package com.sunwayworld.basemodule.business.batchrevise.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.business.batchrevise.dao.LimsBatchSampleProductTempDao;
import com.sunwayworld.basemodule.business.batchrevise.bean.LimsBatchSampleProductTempBean;
import com.sunwayworld.basemodule.business.batchrevise.service.LimsBatchSampleProductTempService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsBatchSampleProductTempServiceImpl implements LimsBatchSampleProductTempService {

    @Autowired
    private LimsBatchSampleProductTempDao limsBatchSampleProductTempDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsBatchSampleProductTempDao getDao() {
        return limsBatchSampleProductTempDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsBatchSampleProductTempBean limsBatchSampleProductTemp = jsonWrapper.parseUnique(LimsBatchSampleProductTempBean.class);
        limsBatchSampleProductTemp.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsBatchSampleProductTemp);
        return limsBatchSampleProductTemp.getId();
    }

}
